<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Pages - jQuery Mobile Demos</title>
    <link rel="stylesheet" href="../../css/themes/default/jquery.mobile-1.3.1.min.css">
    <link rel="stylesheet" href="../../_assets/css/jqm-demos.css">
    <link rel="shortcut icon" href="../../favicon.ico">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
    <script src="../../js/jquery.js"></script>
    <script src="../../_assets/js/index.js"></script>
    <script src="../../js/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" class="jqm-demos" data-quicklinks="true">

<div data-role="header" class="jqm-header">
<h1 class="jqm-logo"><a href="../../"><img src="../../_assets/img/jquery-logo.png" alt="jQuery Mobile Framework"></a>
</h1>
<a href="#" class="jqm-navmenu-link" data-icon="bars" data-iconpos="notext">Navigation</a>
<a href="#" class="jqm-search-link" data-icon="search" data-iconpos="notext">Search</a>

<div class="jqm-search">
<ul class="jqm-list">
<li data-section="Widgets" data-filtertext="accordions collapsible sets content formatting grouped inset mini"><a
        href="widgets/accordions/">Accordion</a></li>

<li data-section="Widgets" data-filtertext="ajax navigation navigate event method"><a href="widgets/navigation/"
                                                                                      data-ajax="false">AJAX
    Navigation</a></li>

<li data-section="Widgets"
    data-filtertext="autocomplete filter reveal listviews remote listviewbeforefilter placeholder"><a
        href="widgets/autocomplete/" data-ajax="false">Autocomplete</a></li>

<li data-section="Widgets" data-filtertext="buttons inputs forms inline theme grouped icons mini disabled"><a
        href="widgets/buttons/" data-ajax="false">Buttons</a></li>

<li data-section="Widgets" data-filtertext="checkboxes checkboxradio inputs forms mini disabled"><a
        href="widgets/checkbox/">Checkboxes</a></li>

<li data-section="Widgets" data-filtertext="collapsibles content formatting"><a href="widgets/collapsibles/"
                                                                                data-ajax="false">Collapsibles</a></li>

<li data-section="Widgets" data-filtertext="controlgroups selects checkboxradio buttons horizontal vertical"><a
        href="widgets/controlgroups/">Controlgroup</a></li>

<li data-section="Widgets" data-filtertext="dialogs modal popups"><a href="widgets/dialog/">Dialogs</a></li>

<li data-section="Widgets" data-filtertext="fixed toolbars headers footers sections fullscreen"><a
        href="widgets/fixed-toolbars/">Fixed toolbars</a></li>

<li data-section="Widgets" data-filtertext="flip toggle switch binary slider selects forms disabled"><a
        href="widgets/sliders/switch.html" data-ajax="false">Flip switch toggle</a></li>

<li data-section="Widgets" data-filtertext="footer toolbars footers sections"><a href="widgets/footers/">Footer
    toolbar</a></li>

<li data-section="Widgets"
    data-filtertext="forms inputs slider button range toggle switch label disabled accessible fieldcontains elements"><a
        href="widgets/forms/">Form elements</a></li>

<li data-section="Widgets" data-filtertext="grids columns blocks content formatting rwd responsive"><a
        href="widgets/grids/">Grids</a></li>

<li data-section="Widgets" data-filtertext="header toolbars fixed fullscreen sections"><a href="widgets/headers/">Header
    toolbar</a></li>

<li data-section="Widgets" data-filtertext="icons buttons disc position"><a href="widgets/icons/">Icons</a></li>

<li data-section="Widgets" data-filtertext="links navigation ajax prefetch cache"><a href="widgets/links/">Links</a>
</li>

<li data-section="Widgets" data-filtertext="listviews thumbnails icons nested split button collapsible ul ol"><a
        href="widgets/listviews/" data-ajax="false">Listviews</a></li>

<li data-section="Widgets" data-filtertext="ajax loader overlay spinner pages"><a href="widgets/loader/"
                                                                                  data-ajax="false">Loader overlay</a>
</li>

<li data-section="Widgets" data-filtertext="navbars navmenu toolbars links icons footer header"><a
        href="widgets/navbar/" data-ajax="false">Navbar</a></li>

<li data-section="Widgets" data-filtertext="navbars persistent header footer links navmenu"><a
        href="widgets/fixed-toolbars/footer-persist-a.html">Navbar, persistent</a></li>

<li data-section="Widgets" data-filtertext="pages single multipage templates ajax nav"><a
        href="widgets/pages/">Pages</a></li>

<li data-section="Widgets"
    data-filtertext="panels sliding nav modal transition display reveal overlay push rwd responsive"><a
        href="widgets/panels/">Panels <span class="ui-li-count">New</span></a></li>

<li data-section="Widgets"
    data-filtertext="popup dialog modal transition tooltip lightbox form overlay screen flip pop fade transition"><a
        href="widgets/popup/">Popup</a></li>

<li data-section="Widgets" data-filtertext="radiobuttons checkboxradio inputs forms disabled grouped"><a
        href="widgets/radiobuttons/">Radio buttons</a></li>

<li data-section="Widgets" data-filtertext="selectmenus custom native multiple optgroup disabled forms"><a
        href="widgets/selects/">Select</a></li>

<li data-section="Widgets" data-filtertext="slider, single sliders range inputs forms disabled"><a
        href="widgets/sliders/" data-ajax="false">Slider, single</a></li>

<li data-section="Widgets" data-filtertext="slider, dual range sliders rangesliders inputs forms disabled"><a
        href="widgets/sliders/rangeslider.html" data-ajax="false">Slider, dual range <span
        class="ui-li-count">New</span></a></li>

<li data-section="Widgets" data-filtertext="tables column th td toggle responsive tables rwd hide show tabular"><a
        href="widgets/table-column-toggle/">Table, column toggle <span class="ui-li-count">New</span></a></li>

<li data-section="Widgets" data-filtertext="tables reflow th td responsive rwd columns tabular"><a
        href="widgets/table-reflow/">Table, reflow <span class="ui-li-count">New</span></a></li>

<li data-section="Widgets"
    data-filtertext="text inputs textarea numeric email tel file date time month clear pattern placeholder forms"><a
        href="widgets/textinputs/">Text inputs & textarea</a></li>

<li data-section="Widgets" data-filtertext="page transitions animated pages ajax navigation flip slide fade pop"
    data-ajax="false"><a href="widgets/transitions/" data-ajax="false">Transitions</a></li>

<li data-role="list-divider">Collapsibles</li>

<li data-section="Demo Showcase" data-filtertext="dynamic collapsible set accordion append expand"><a
        href="examples/collapsibles/dynamic-collapsible.html" data-ajax="false">Dynamic collapsible</a></li>

<li data-role="list-divider">Controlgroups</li>

<li data-section="Demo Showcase" data-filtertext="dynamic controlgroup buttons selects checkboxes forms"><a
        href="examples/controlgroups/dynamic-controlgroup.html" data-ajax="false">Dynamic controlgroup</a></li>

<li data-role="list-divider">Listviews</li>

<li data-section="Demo Showcase" data-filtertext="grid listview responsive grids responsive listviews lists ul"><a
        href="examples/listviews/grid-listview.html" data-ajax="false">Grid Listview</a></li>

<li data-section="Demo Showcase" data-filtertext="autodividers anchor jump scroll linkbars listviews lists ul"><a
        href="examples/listviews/autodividers-linkbar.html" data-ajax="false">Autodividers Linkbar</a></li>

<li data-section="Demo Showcase" data-filtertext="listviews autodividers selector autodividersselector lists ul ol"><a
        href="examples/listviews/autodividers-selector.html" data-ajax="false">Autodividers Selector</a></li>

<li data-role="list-divider">Navigation</li>

<li data-section="Demo Showcase" data-filtertext="backbone and require.js example navigation router"><a
        href="examples/backbone-require/index.html" data-ajax="false">Backbone and Require.js example</a></li>

<li data-section="Demo Showcase" data-filtertext="server redirection with server-side support php"><a
        href="examples/redirect/" data-ajax="false">Redirection with server-side support</a></li>

<li data-role="list-divider">Panels</li>

<li data-section="Demo Showcase"
    data-filtertext="panel styling slide panels sliding panels shadow rwd responsive breakpoint"><a
        href="examples/panels/panel-styling.html" data-ajax="false">Panel styling</a></li>

<li data-section="Demo Showcase" data-filtertext="open panel on swipe panels left right"><a
        href="examples/panels/panel-swipe-open.html" data-ajax="false">Open panel on swipe</a></li>

<li data-role="list-divider">Popups</li>

<li data-section="Demo Showcase" data-filtertext="dynamic popups popup images lightbox"><a
        href="examples/popups/dynamic-popup.html" data-ajax="false">Dynamic popup</a></li>

<li data-section="Demo Showcase" data-filtertext="arrow popups popover"><a href="examples/popups/arrow.html"
                                                                           data-ajax="false">Popup with arrow</a></li>

<li data-role="list-divider">Responsive Tables</li>

<li data-section="Demo Showcase" data-filtertext="responsive tables reflow stack custom styles"><a
        href="examples/tables/movie-list.html" data-ajax="false">Reflow: Custom styles</a></li>

<li data-section="Demo Showcase" data-filtertext="responsive tables reflow heading groups rwd breakpoint"><a
        href="examples/tables/financial-grouped-reflow.html" data-ajax="false">Reflow: Heading groups</a></li>

<li data-section="Demo Showcase" data-filtertext="responsive tables reflow refresh method dynamically inject data"><a
        href="examples/tables/reflow-refresh.html" data-ajax="false">Reflow: Refresh method</a></li>

<li data-section="Demo Showcase"
    data-filtertext="responsive tables column toggle hide rwd breakpoint customization options"><a
        href="examples/tables/movie-list-toggle-options.html" data-ajax="false">Column toggle: Customization options</a>
</li>

<li data-section="Demo Showcase" data-filtertext="responsive tables column toggle heading groups rwd breakpoint"><a
        href="examples/tables/financial-grouped-columns.html" data-ajax="false">Column toggle: Heading groups</a></li>

<li data-section="Demo Showcase"
    data-filtertext="responsive tables column toggle refresh method dynamically inject data"><a
        href="examples/tables/columntoggle-refresh.html" data-ajax="false">Column toggle: Refresh method</a></li>

<li data-section="Demo Showcase"
    data-filtertext="responsive tables table column toggle phone comparison rwd breakpoint"><a
        href="examples/tables/phone-compare.html" data-ajax="false">Column toggle demo: Phone comparison</a></li>

<li data-role="list-divider">Sliders</li>

<li data-section="Demo Showcase" data-filtertext="slider tooltip handle value extension input range sliders forms"><a
        href="examples/slider/tooltip.html" data-ajax="false">Tooltip extension</a></li>

<li data-role="list-divider">Swipe</li>

<li data-section="Demo Showcase" data-filtertext="swipe to navigate page transitions navigation"><a
        href="examples/swipe/swipe-page.html" data-ajax="false">Swipe to navigate</a></li>

<li data-section="Demo Showcase" data-filtertext="swipe to delete list item listviews lists ul ol"><a
        href="examples/swipe/swipe-list.html" data-ajax="false">Swipe to delete list item</a></li>

<li data-role="list-divider">Forms</li>

<li data-section="Questions & Answers" data-filtertext="CSS styles apply widget scope wrap selector customize"><a
        href="faq/question-template.html">Why won't my CSS styles apply correctly to a widget?</a></li>

<li data-section="Questions & Answers" data-filtertext="form update value enhance pageinit refresh"><a
        href="faq/updating-the-value-of-enhanced-form-elements-does-not-work.html">Updating the value of enhanced form
    elements does not work.</a></li>

<li data-section="Questions & Answers"
    data-filtertext="HTML 5 inputs appearance keyboard picker calendar date time slider file color"><a
        href="faq/my-html-5-inputs-look-different-in-browsers.html">My HTML 5 inputs look different across devices and
    browsers.</a></li>

<li data-section="Questions & Answers" data-filtertext="range search inputs slider number text degrade"><a
        href="faq/my-range-search-input-type-is-being-changed.html">My range or search inputs are being change to
    number/text.</a></li>

<li data-section="Questions & Answers" data-filtertext="custom select popup dialog logic"><a
        href="faq/sometimes-custom-select-shows-as-dialog-popup.html">Sometimes my custom select shows as a popup other
    times its a dialog.</a></li>

<li data-section="Questions & Answers" data-filtertext="disable button issue class method"><a
        href="faq/disabling-a-button-does-not-work.html">Disabling a button does not work.</a></li>

<li data-section="Questions & Answers" data-filtertext="fixed toolbar header footer fullscreen select input bug issue">
    <a href="faq/controls-in-header-footer.html">Controls in my fixed header or footer are not responding or behave
        erratically.</a></li>

<li data-role="list-divider">Pages</li>

<li data-section="Questions & Answers"
    data-filtertext="head load scripts styles pageinit onload pagebeforecreate ajax nav pages"><a
        href="faq/scripts-and-styles-not-loading.html">Why aren't my scripts and styles loading?</a></li>

<li data-section="Questions & Answers" data-filtertext="document.ready onload paginit DOM ready on ready scripts "><a
        href="faq/dom-ready-not-working.html">Why isn't DOM ready working for my scripts?</a></li>

<li data-section="Questions & Answers" data-filtertext="ajax nav load page mobile.loadpage"><a
        href="faq/how-do-i-load-a-page.html">How do I load a page?</a></li>

<li data-section="Questions & Answers" data-filtertext="ajax nav multi page document load"><a
        href="faq/why-is-only-the-first-page-loaded.html">Why is only the first page of my multi page document
    loaded?</a></li>

<li data-section="Questions & Answers" data-filtertext="pass url query params ajax nav"><a
        href="faq/pass-query-params-to-page.html">I'm trying to pass query params to a page but it's not working?</a>
</li>

<li data-section="Questions & Answers" data-filtertext="hash pass parameters information ajax nav"><a
        href="faq/pass-via-the-hash-to-page.html">I'm trying to pass information via the hash but it's not working?</a>
</li>

<li data-section="Questions & Answers" data-filtertext="application cache status error isLocal ajax nav"><a
        href="faq/the-application-cache-is-not-working.html">I'm trying to use the application cache but it's not
    working.</a></li>

<li data-section="Questions & Answers"
    data-filtertext=">create refresh event trigger pageInit refresh method content injected page not enhanced."><a
        href="faq/injected-content-is-not-enhanced.html">Content injected into a page is not enhanced.</a></li>

<li data-section="Questions & Answers" data-filtertext=">create trigger event pageInit injected HTML"><a
        href="faq/triggering-create-on-injected-content-does-not-work.html">Triggering create on injected HTML does not
    work.</a></li>

<li data-section="Questions & Answers" data-filtertext="auto-enhance element stop preventnative role none"><a
        href="faq/how-can-i-stop-auto-enhancement-of-elements.html">How can I stop JQM from auto-enhancing an
    element?</a></li>

<li data-section="Questions & Answers"
    data-filtertext="auto-enhance block container parent stop preventnative role none"><a
        href="faq/how-can-i-stop-auto-enhancement-of-a-block-of-elements.html">How can I stop JQM from enhancing a block
    of elements?</a></li>

<li data-section="Questions & Answers" data-filtertext="page title ajax nav head"><a
        href="faq/how-do-i-control-page-titles.html">How do I control page titles?</a></li>

<li data-section="Questions & Answers" data-filtertext="ajax nav load page loadPage"><a
        href="faq/how-do-i-load-a-page.html">How do I load a page?</a></li>

<li data-role="list-divider">Events</li>

<li data-section="Questions & Answers"
    data-filtertext="touch mouse events vmouseover, vmousedown, vmousemove, vmouseup, vclick, vmousecancel"><a
        href="faq/how-do-i-use-touch-mouse-events.html">How do I use touch and mouse events?</a></li>

<li data-role="list-divider">Theme and styling</li>

<li data-section="Questions & Answers"
    data-filtertext="theme swatch css themeroller customize icons colors fonts style"><a
        href="faq/how-does-theming-work.html">How does theming work?</a></li>

<li data-role="list-divider">Apps</li>

<li data-section="Questions & Answers" data-filtertext="How do I need to configure PhoneGap Cordova?"><a
        href="faq/how-configure-phonegap-cordova.html">How do I need to configure PhoneGap/Cordova?</a></li>
<!--
<li data-role="list-divider">Navigation</li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/nav-is-acting-erraticly.html">The nav is acting erratically!</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/deep-links-dont-work.html">Following a deep link ( a link to scroll to and id ) does not work.</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/scripts-css-only-works-on-first-page-or-refresh.html">My script / css only works on first page or on refresh.</a></li>
<li data-role="list-divider">Widgets</li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/cloned-content-double-enhanced.html">Cloning a widget or enhanced for element and enhancing causes "double" enhancement</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/cloned-content-does-not-update.html">Cloned widget or enhanced element does not update</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/data-enhance-false-does-not-work.html">Setting data-enhance="false" does not work.</a></li>

<li data-role="list-divider">General</li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/selecting-element-by-id-not-working.html">Selecting elements by id only works sometimes or on first page!</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/global-config-settings-ignored.html">The global configuration settings i set are being ignored.</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/custom-css-is-ignored.html">My custom css is ignored.</a></li>

<li data-role="list-divider">Events</li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/swipe-triggered-when-scrolling.html">Swipe triggered when scrolling.</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/document-ready-not-working.html">Document ready ignored after first page.</a></li>

<li data-role="list-divider">Theming &amp; custom styles</li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/#">How do I add custom icons?</a></li>

<li data-section="Questions & Answers" data-filtertext=""><a href="faq/#">How do I add remove the circle behind the icons?</a></li>
-->

</ul>
</div>

</div>
<!-- /header -->

<div data-role="content" class="jqm-content">

<h1>Pages <a href="http://api.jquerymobile.com/page/" data-ajax="false" data-role="button" data-inline="true"
             data-mini="true" data-icon="arrow-r" data-iconpos="right" class="jqm-api-link">API</a></h1>

<p class="jqm-intro">
    The page is the primary unit of interaction in jQuery Mobile and is used to group content into logical views that
    can be animated in and out of view with page transitions. A HTML document may start with a single "page" and the
    AJAX navigation system will load additional pages on demand into the DOM as users navigate around. Alternatively, a
    HTML document can be built with multiple "pages" inside it and the framework will transition between these local
    views with no need to request content from the server.
</p>

<h2>Mobile page structure</h2>

<p>A jQuery Mobile site must start with an HTML5 <code>doctype</code> to take full advantage of all of the framework's
    features. (Older devices with browsers that don't understand HTML5 will safely ignore the 'doctype' and various
    custom attributes.) </p>

<p>In the <code>head</code>, references to jQuery, jQuery Mobile and the mobile theme CSS are all required to start
    things off. jQuery Mobile 1.3.1 works with versions of jQuery core from 1.7.0 to 1.9.1. The easiest way to get
    started is to link to files hosted on the jQuery CDN or for best performance, <a
            href="http://jquerymobile.com/download-builder/" rel="external">build a custom bundle</a>:</p>

<pre><code>
    <strong>&lt;!DOCTYPE html&gt; </strong>
    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;Page Title&lt;/title&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css&quot;
    /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-1.9.1.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;

    &lt;body&gt;
    ...content goes here...
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<h2>Viewport meta tag</h2>

<p>Note above that there is a meta <code>viewport</code> tag in the <code>head</code> to specify how the browser should
    display the page zoom level and dimensions. If this isn't set, many mobile browsers will use a "virtual" page width
    around 900 pixels to make it work well with existing desktop sites but the screens may look zoomed out and too wide.
    By setting the viewport attributes to <code>content=&quot;width=device-width, initial-scale=1&quot;</code>, the
    width will be set to the pixel width of the device screen. </p>

<pre><code>
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
</code></pre>

<p>These settings do not disable the user's ability to zoom the pages, which is nice from an accessibility perspective.
    There is a minor issue in iOS that doesn't properly set the width when changing orientations with these viewport
    settings, but this will hopefully be fixed in a future release. You can set other viewport values to disable zooming
    if required since this is part of your page content, not the library. </p>


<h2>Inside the body: Pages</h2>

<p>Inside the <code>&lt;body&gt;</code> tag, each view or "page" on the mobile device is identified with an element
    (usually a <code>div</code>) with the <code> data-role="page"</code> attribute. </p>

<pre><code>
    &lt;div data-role="page"&gt;
    ...
    &lt;/div&gt;
</code></pre>

<p>Within the "page" container, any valid HTML markup can be used, but for typical pages in jQuery Mobile, the immediate
    children of a "page" are divs with data-roles of <code>"header"</code>, <code>"content"</code>, and
    <code>"footer"</code>.</p>


<pre><code>
    &lt;div data-role="page"&gt;
    &lt;div data-role="header"&gt;...&lt;/div&gt;
    &lt;div data-role="content"&gt;...&lt;/div&gt;
    &lt;div data-role="footer"&gt;...&lt;/div&gt;
    &lt;/div&gt;</span>
</code></pre>


<h2>Putting it together: Basic single page template</h2>

<p>Putting it all together, this is the standard boilerplate page template you should start with on a project: </p>

<pre><code>
    &lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;Page Title&lt;/title&gt;

    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;

    &lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css&quot;
    /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-1.9.1.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;

    &lt;div data-role=&quot;page&quot;&gt;

    &lt;div data-role=&quot;header&quot;&gt;
    &lt;h1&gt;Page Title&lt;/h1&gt;
    &lt;/div&gt;&lt;!-- /header --&gt;

    &lt;div data-role=&quot;content&quot;&gt;
    &lt;p&gt;Page content goes here.&lt;/p&gt;
    &lt;/div&gt;&lt;!-- /content --&gt;

    &lt;div data-role=&quot;footer&quot;&gt;
    &lt;h4&gt;Page Footer&lt;/h4&gt;
    &lt;/div&gt;&lt;!-- /footer --&gt;
    &lt;/div&gt;&lt;!-- /page --&gt;

    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<a href="page-template.html" class="jqm-button" data-ajax="false" data-role="button" data-inline="true" data-mini="true"
   data-icon="arrow-r" data-iconpos="right">View page template</a>

<h2>Multi-page template structure</h2>

<p>A single HTML document can contain multiple "pages" that are loaded together by stacking multiple divs with a <code>data-role</code>
    of <code>"page"</code>. Each "page" block needs a unique id (<code>id="foo"</code>) that will be used to link
    internally between "pages" (<code>href="#foo"</code>). When a link is clicked, the framework will look for an
    internal "page" with the id and transition it into view.</p>

<p>Here is an example of a two "page" site built with two jQuery Mobile divs navigated by linking to an id placed on
    each page wrapper. Note that the ids on the page wrappers are only needed to support the internal page linking, and
    are optional if each page is a separate HTML document. Here is what two pages look like inside the <code>body</code>
    element.</p>

<pre><code>
    &lt;body&gt;

    &lt;!-- Start of first page --&gt;
    &lt;div data-role=&quot;page&quot; id=&quot;foo&quot;&gt;

    &lt;div data-role=&quot;header&quot;&gt;
    &lt;h1&gt;Foo&lt;/h1&gt;
    &lt;/div&gt;&lt;!-- /header --&gt;

    &lt;div data-role=&quot;content&quot;&gt;
    &lt;p&gt;I&#x27;m first in the source order so I&#x27;m shown as the page.&lt;/p&gt;
    &lt;p&gt;View internal page called &lt;a href=&quot;#bar&quot;&gt;bar&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;&lt;!-- /content --&gt;

    &lt;div data-role=&quot;footer&quot;&gt;
    &lt;h4&gt;Page Footer&lt;/h4&gt;
    &lt;/div&gt;&lt;!-- /footer --&gt;
    &lt;/div&gt;&lt;!-- /page --&gt;

    &lt;!-- Start of second page --&gt;
    &lt;div data-role=&quot;page&quot; id=&quot;bar&quot;&gt;

    &lt;div data-role=&quot;header&quot;&gt;
    &lt;h1&gt;Bar&lt;/h1&gt;
    &lt;/div&gt;&lt;!-- /header --&gt;

    &lt;div data-role=&quot;content&quot;&gt;
    &lt;p&gt;I&#x27;m the second in the source order so I&#x27;m hidden when the page loads. I&#x27;m just shown if a
    link that references my id is beeing clicked.&lt;/p&gt;
    &lt;p&gt;&lt;a href=&quot;#foo&quot;&gt;Back to foo&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;&lt;!-- /content --&gt;

    &lt;div data-role=&quot;footer&quot;&gt;
    &lt;h4&gt;Page Footer&lt;/h4&gt;
    &lt;/div&gt;&lt;!-- /footer --&gt;
    &lt;/div&gt;&lt;!-- /page --&gt;
    &lt;/body&gt;
</code></pre>

<a href="multipage-template.html" class="jqm-button" data-ajax="false" data-role="button" data-inline="true"
   data-mini="true" data-icon="arrow-r" data-iconpos="right">View multi-page template</a>

<p>PLEASE NOTE: Since we are using the hash to track navigation history for all the AJAX "pages", it's not currently
    possible to deep link to an anchor (<code>index.html#foo</code>) on a page in jQuery Mobile, because the framework
    will look for a "page" with an <code>id</code> of <code>#foo</code> instead of the native behavior of scrolling to
    the content with that <code>id</code>.</p>

<p>The <code>id</code> attribute of all your elements must be not only unique on a given page, but also unique across
    the pages in a site. This is because jQuery Mobile's single-page navigation model allows many different "pages" to
    be present in the DOM at the same time. This also applies when using a multi-page template, since all "pages" on the
    template are loaded at once.</p>

<h2>Conventions, not requirements</h2>

<p>Although the page structure outlined above is a recommended approach for a standard web app built with jQuery Mobile,
    the framework is very flexible with document structure.
    The page, header, content, and footer data-role elements are optional and are mostly helpful for providing some
    basic formatting and structure.
    The page wrapper that used to be required for auto-initialization to work is now optional for single page documents,
    so there isn't any required markup at all.
    For a web page with a custom layout, all of these structural elements can be omitted and the AJAX navigation and all
    widgets will work just like they do in the boilerplate structure.
    Behind the scenes, the framework will inject the page wrapper if it's not included in the markup because it's needed
    for managing pages, but the starting markup can now be extremely simple. </p>

<p><strong>Note:</strong> In a multi-page setup, you are required to have page wrappers in your markup in order to group
    the content into multiple pages.</p>

<p><strong>Also Note:</strong> If your body contains no <code>data-role="page"</code> divs, jQuery Mobile wraps the
    entire contents of the body within a page div as explained above.
    jQuery Mobile is using jQuery's <code>wrapAll()</code> method to do this which looks for any script tags inside the
    content being wrapped, and loads each script source via XHR.
    If scripts are present in the body, the browser ends up loading them twice.
    We therefore strongly recommend that jQuery Mobile documents with scripts in their body also contain a
    <code>div</code> with <code>data-role="page"</code>.
</p>

<h2 id="nav-prefetch">Prefetching pages</h2>

<p>When using single-page templates, you can prefetch pages into the DOM so that they're available instantly when the
    user visits them. To prefetch a page, add the <code>data-prefetch</code> attribute to a link that points to the
    page. jQuery Mobile then loads the target page in the background after the primary page has loaded and the <code>pagecreate</code>
    event has triggered.

<div data-demo-html="true">

    <a href="../dialog/dialog-alt.html" data-prefetch="true" data-rel="dialog">This link will prefetch the page</a>

</div>
<!--/demo-html -->

<p>Alternatively, you can prefetch a page programmatically using <code>$.mobile.loadPage()</code>:</p>

<pre><code>
    $.mobile.loadPage( <var>pageUrl</var>, { showLoadMsg: false } );
</code></pre>

<h2 id="nav-cache">DOM Cache</h2>

<p>Keeping lots of pages in the DOM quickly fills the browser's memory, and can cause some mobile browsers to slow down
    or even crash. jQuery Mobile has a simple mechanism to keep the DOM tidy. </p>

<p>Whenever it loads a page via AJAX, it flags the page to be removed from the DOM when you navigate away from it later
    (technically, on the <code>pagehide</code> event). If you revisit a removed page, the browser may be able to
    retrieve the page's HTML file from its cache. If not, it re-fetches the file from the server. (In the case of nested
    listviews, jQuery Mobile removes all the pages that make up the nested list once you navigate to a page that's not
    part of the list.)</p>

<p>If you prefer, you can tell jQuery Mobile to keep previously-visited pages in the DOM instead of removing them. This
    lets you cache pages so that they're available instantly if the user returns to them.</p>

<pre><code>
    $.mobile.page.prototype.options.domCache = true;
</code></pre>

<p>Alternatively, to cache just a particular page, you can add the <code>data-dom-cache="true"</code> attribute to the
    page's container. </p>

<p>To keep all previously-visited pages in the DOM, set the <code>domCache</code> option on the page plugin to <code>true</code>,
    like this:</p>

<pre><code>
    <var>pageContainerElement</var>.page({ domCache: true });
</code></pre>

<p>Note that the contents of the first page isn't removed from the DOM, only pages loaded in via AJAX. Pages inside a
    multi-page template aren't affected by this feature at all - jQuery Mobile only removes pages loaded via AJAX.</p>

</div>
<!-- /content -->

<div data-role="footer" class="jqm-footer">
    <p class="jqm-version"></p>

    <p>Copyright 2013 The jQuery Foundation</p>
</div>
<!-- /footer -->
<div data-role="panel" class="jqm-nav-panel jqm-navmenu-panel" data-position="left" data-display="reveal"
     data-theme="c">
    <ul data-role="listview" data-theme="d" data-divider-theme="d" data-icon="false" data-global-nav="demos"
        class="jqm-list">
        <li data-role="list-divider">jQuery Mobile Demos</li>
        <li><a href="./">Home</a></li>
        <li><a href="intro/">Introduction</a></li>
        <li><a href="examples/">Demo Showcase</a></li>
        <li><a href="faq/">Questions & Answers</a></li>
        <li><a href="intro/rwd.html">Going Responsive</a></li>
        <li data-role="list-divider">Widget reference</li>
        <li data-section="Widgets" data-filtertext="accordions collapsible sets content formatting grouped inset mini">
            <a href="widgets/accordions/">Accordion</a></li>

        <li data-section="Widgets" data-filtertext="ajax navigation navigate event method"><a href="widgets/navigation/"
                                                                                              data-ajax="false">AJAX
            Navigation</a></li>

        <li data-section="Widgets"
            data-filtertext="autocomplete filter reveal listviews remote listviewbeforefilter placeholder"><a
                href="widgets/autocomplete/" data-ajax="false">Autocomplete</a></li>

        <li data-section="Widgets" data-filtertext="buttons inputs forms inline theme grouped icons mini disabled"><a
                href="widgets/buttons/" data-ajax="false">Buttons</a></li>

        <li data-section="Widgets" data-filtertext="checkboxes checkboxradio inputs forms mini disabled"><a
                href="widgets/checkbox/">Checkboxes</a></li>

        <li data-section="Widgets" data-filtertext="collapsibles content formatting"><a href="widgets/collapsibles/"
                                                                                        data-ajax="false">Collapsibles</a>
        </li>

        <li data-section="Widgets" data-filtertext="controlgroups selects checkboxradio buttons horizontal vertical"><a
                href="widgets/controlgroups/">Controlgroup</a></li>

        <li data-section="Widgets" data-filtertext="dialogs modal popups"><a href="widgets/dialog/">Dialogs</a></li>

        <li data-section="Widgets" data-filtertext="fixed toolbars headers footers sections fullscreen"><a
                href="widgets/fixed-toolbars/">Fixed toolbars</a></li>

        <li data-section="Widgets" data-filtertext="flip toggle switch binary slider selects forms disabled"><a
                href="widgets/sliders/switch.html" data-ajax="false">Flip switch toggle</a></li>

        <li data-section="Widgets" data-filtertext="footer toolbars footers sections"><a href="widgets/footers/">Footer
            toolbar</a></li>

        <li data-section="Widgets"
            data-filtertext="forms inputs slider button range toggle switch label disabled accessible fieldcontains elements">
            <a href="widgets/forms/">Form elements</a></li>

        <li data-section="Widgets" data-filtertext="grids columns blocks content formatting rwd responsive"><a
                href="widgets/grids/">Grids</a></li>

        <li data-section="Widgets" data-filtertext="header toolbars fixed fullscreen sections"><a
                href="widgets/headers/">Header toolbar</a></li>

        <li data-section="Widgets" data-filtertext="icons buttons disc position"><a href="widgets/icons/">Icons</a></li>

        <li data-section="Widgets" data-filtertext="links navigation ajax prefetch cache"><a
                href="widgets/links/">Links</a></li>

        <li data-section="Widgets" data-filtertext="listviews thumbnails icons nested split button collapsible ul ol"><a
                href="widgets/listviews/" data-ajax="false">Listviews</a></li>

        <li data-section="Widgets" data-filtertext="ajax loader overlay spinner pages"><a href="widgets/loader/"
                                                                                          data-ajax="false">Loader
            overlay</a></li>

        <li data-section="Widgets" data-filtertext="navbars navmenu toolbars links icons footer header"><a
                href="widgets/navbar/" data-ajax="false">Navbar</a></li>

        <li data-section="Widgets" data-filtertext="navbars persistent header footer links navmenu"><a
                href="widgets/fixed-toolbars/footer-persist-a.html">Navbar, persistent</a></li>

        <li data-section="Widgets" data-filtertext="pages single multipage templates ajax nav"><a href="widgets/pages/">Pages</a>
        </li>

        <li data-section="Widgets"
            data-filtertext="panels sliding nav modal transition display reveal overlay push rwd responsive"><a
                href="widgets/panels/">Panels <span class="ui-li-count">New</span></a></li>

        <li data-section="Widgets"
            data-filtertext="popup dialog modal transition tooltip lightbox form overlay screen flip pop fade transition">
            <a href="widgets/popup/">Popup</a></li>

        <li data-section="Widgets" data-filtertext="radiobuttons checkboxradio inputs forms disabled grouped"><a
                href="widgets/radiobuttons/">Radio buttons</a></li>

        <li data-section="Widgets" data-filtertext="selectmenus custom native multiple optgroup disabled forms"><a
                href="widgets/selects/">Select</a></li>

        <li data-section="Widgets" data-filtertext="slider, single sliders range inputs forms disabled"><a
                href="widgets/sliders/" data-ajax="false">Slider, single</a></li>

        <li data-section="Widgets" data-filtertext="slider, dual range sliders rangesliders inputs forms disabled"><a
                href="widgets/sliders/rangeslider.html" data-ajax="false">Slider, dual range <span class="ui-li-count">New</span></a>
        </li>

        <li data-section="Widgets" data-filtertext="tables column th td toggle responsive tables rwd hide show tabular">
            <a href="widgets/table-column-toggle/">Table, column toggle <span class="ui-li-count">New</span></a></li>

        <li data-section="Widgets" data-filtertext="tables reflow th td responsive rwd columns tabular"><a
                href="widgets/table-reflow/">Table, reflow <span class="ui-li-count">New</span></a></li>

        <li data-section="Widgets"
            data-filtertext="text inputs textarea numeric email tel file date time month clear pattern placeholder forms">
            <a href="widgets/textinputs/">Text inputs & textarea</a></li>

        <li data-section="Widgets" data-filtertext="page transitions animated pages ajax navigation flip slide fade pop"
            data-ajax="false"><a href="widgets/transitions/" data-ajax="false">Transitions</a></li>

    </ul>
</div>
<!-- /panel -->


</div>
<!-- /page -->
</body>
</html>
